<template>
  <common-card
  title="累计用户数"
  value="1,087,507">
    <template>
      <v-chart :option="getOptions()" class="echarts"/>
    </template>
    <template v-slot:footer>
      <div class="total-users-footer">
        <span>日同比</span>
        <span class="emphasis">8.75%</span>
        <div class="increase" />
        <span class="month">月同比</span>
        <span class="emphasis">35.96%</span>
        <div class="decrease" />
      </div>
    </template>
  </common-card>
</template>

<script>
import commonCardMixin from '../../mixins/commonCardMixin'
import commonDataMixin from '../../mixins/commonDataMixin'

export default {
  mixins: [commonCardMixin, commonDataMixin],
  methods: {
    getOptions () {
      return {
        xAxis: {
          type: 'value',
          show: false
        },
        yAxis: {
          type: 'category',
          show: false
        },
        series: [{
          type: 'bar',
          stack: '总量',
          data: [200],
          barWidth: 10,
          itemStyle: {
            color: '#45c946'
          }
        }, {
          type: 'bar',
          stack: '总量',
          data: [250],
          itemStyle: {
            color: '#eee'
          }
        }, {
          type: 'custom',
          data: [200],
          stack: '总量',
          renderItem: (params, api) => {
            const value = api.value(0)
            const endPonit = api.coord([value, 0])
            return {
              type: 'group',
              position: endPonit,
              children: [{
                type: 'path',
                shape: {
                  d: 'M512 682.666667l298.666667-298.666667H213.333333z',
                  x: -6,
                  y: -20,
                  width: 10,
                  height: 10
                },
                style: {
                  fill: '#45c946'
                }
              }, {
                type: 'path',
                shape: {
                  d: 'M512 341.333333l-298.666667 298.666667h597.333334z',
                  x: -6,
                  y: 10,
                  width: 10,
                  height: 10
                },
                style: {
                  fill: '#45c946'
                }
              }]
            }
          }
        }],
        grid: {
          top: 0,
          bottom: 0,
          left: 0,
          right: 0
        }
      }
    }
  }
}

</script>
<style lang="scss" scoped>
.total-users-footer {
  display: flex;
  align-items: center;

  .month {
    margin-left: 10px;
  }
}
</style>

<svg t="1642394950442" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2401" width="200" height="200"><path d="M512 682.666667l298.666667-298.666667H213.333333z" fill="#444444" p-id="2402"></path></svg>
